package com.smiletrain.view;

import com.smiletrain.R;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ItemList {

	public ItemList(String text, boolean selected) {
		this.text = text;
		this.selected = selected;
	}
	
	public void generateView(ViewGroup parent) {
		View rview = LayoutInflater.from(parent.getContext())
        		.inflate(R.layout.itemlist, null);
        TextView title = (TextView) rview.findViewById(R.id.titulo);  
        title.setText(text);
        if(selected)
        	title.setBackgroundResource(R.drawable.vista02_item_sel);
        view = rview;
	}
	
	public void setBackground(int background) {
		view.findViewById(R.id.titulo).setBackgroundResource(background);
	}
	
	public void changeState() {
		selected = !selected;
		if(selected)
			setBackground(R.drawable.vista02_item_sel);
		else
			setBackground(R.drawable.vista02_item);
	}
	
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}
	
	public boolean isSelected() {
		return selected;
	}
	
	public void setSelected(boolean selected) {
		this.selected = selected;
	}

	public View getView() {
		return view;
	}

	public void setView(View view) {
		this.view = view;
	}

	private String text = "";
	private boolean selected = false;
	private View view = null;
	
}
